package com.hehan.hhdemo.controller;


import com.github.pagehelper.PageHelper;
import com.hehan.hhdemo.common.resp.ModelResp;
import com.hehan.hhdemo.service.IESService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("es")
@Api("【ES】搜索接口")
public class ESController {

    @Resource
    private IESService ESService;


    @GetMapping("/queryList")
    @ApiOperation("ES查询列表")
    public Map queryList(int pageSize, int pageNum) {
        Map map = new HashMap();
        PageHelper.startPage(pageNum,pageSize);
        List<ModelResp> list =  ESService.queryList();
        map.put("list",list);
        return map;
    }

    @PostMapping("/delEsById")
    @ApiOperation("delEsById")
    public void delEsById(@RequestBody Integer id) {
        ESService.delEsById(id);
    }

    @GetMapping("/testRedis")
    @ApiOperation("testRedis")
    public Map testRedis() {
        Map map = new HashMap();
        List<ModelResp> list =  ESService.testRedis();
        map.put("list",list);
        return map;
    }



}
